package com.toocms.jinjuhang.ui.mine

import android.graphics.drawable.Drawable
import android.os.Bundle
import androidx.databinding.ObservableField
import com.toocms.jinjuhang.ui.base.BaseFgt
import com.toocms.jinjuhang.widget.view_model.checkLoginStatus
import com.toocms.tab.base.ItemViewModel
import com.toocms.tab.binding.command.BindingAction
import com.toocms.tab.binding.command.BindingCommand

class MineFunctionItemModel(
    viewModel: MineModel,
    val iconObservableField: ObservableField<Drawable>,
    val titleObservableField: ObservableField<String>,
    val openFgt: Class<out BaseFgt<*, *>>? = null,
    val bundle: Bundle? = null,
    val isCheckLoginStatus: Boolean = false,
    val itemClickBindingCommand: (BindingCommand<BindingAction>) = BindingCommand<BindingAction>(
        BindingAction {
            if (null == openFgt) return@BindingAction
            if (isCheckLoginStatus && !viewModel.checkLoginStatus()) return@BindingAction
            viewModel.startFragment(openFgt, bundle)
        })
) : ItemViewModel<MineModel>(viewModel) {
}